import sys


def print_chat_message(user_id):
    file_path = "C:\\Users\\Administrator\\Desktop\\金色财经\\im-chat-message.log.bak"  # 替换为实际文件路径

    # 打开文件并读取内容
    with open(file_path, "r", encoding='utf-8') as file:
        content = file.read()
    # 根据换行符分割成字符串数组
    lines = content.split("\n")

    # 打印每行数据
    ct = ''
    for line in lines:
        if not line:
            if "sendUid: " + user_id in ct:
                print(ct)
                # 处理数据
                ct = ''
        else:
            ct += line


def print_socket_message(user_id):
    file_path = "C:\\Users\\Administrator\\Desktop\\金色财经\\im-socket-message.log.bak"
    # 打开文件并读取内容
    with open(file_path, "r", encoding='utf-8') as file:
        content = file.read()
    # 根据换行符分割成字符串数组
    lines = content.split("\n")
    # 打印每行数据
    ct = ''
    for line in lines:
        if not line:
            if "sendUid: " + user_id in ct:
                print(ct)
                # 处理数据
                ct = ''
        else:
            ct += line


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Usage: python script.py <cmd_type> <content_md5>")
        sys.exit(1)

    user_id = sys.argv[1]
    # content_md5 = sys.argv[2]
    print_chat_message(user_id)
    print_socket_message(user_id)

